﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BillGuru.Utilities
{
    class DatabaseUtilities
    {
        public static string createProductDescriptionFilter(string sFilterText)
        {
            string sFilter = null;

            foreach (string tok in sFilterText.Split(new char[] { ',', ' ' }))
            {
                sFilter = sFilter + "FullDescription like '%" + tok + "%' And ";
            }

            if(sFilter != null)
                sFilter = sFilter.Substring(0, sFilter.LastIndexOf("And") - 1);

            return sFilter;
        }

        public static System.Data.OleDb.OleDbConnection createConnection()
        {
            return new System.Data.OleDb.OleDbConnection(BillGuru.Properties.Settings.Default.BillGuruConnectionString);
        }
    }
}
